import { options } from './config'
import { jsonp } from '@/assets/js/jsonp'
export const getProductInfo = (id) => { // 获取商品详情页数据
  const url = 'https://unszacs.m.taobao.com/h5/mtop.taobao.detail.getdetail/6.0'
  const params = {
    api: 'mtop.taobao.detail.getdetail',
    ttid: '2017%40taobao_h5_6.6.0',
    data: `%7B"itemNumId"%3A"${id}"%7D`,
    appKey: 12574478,
    dataType: 'jsonp',
    type: 'jsonp'
  }
  return jsonp(url, options, params)
    .then(res => {
      // console.log('raw-data',res)
      if (res.data) {
        return res.data
      }
      throw new Error('未能获取数据')
    })
    .catch(err => {
      if (err) {
        console.log(err)
      }
    })
}
